package zoo.gwt.client;

import com.google.gwt.dom.client.Element;
import com.google.gwt.user.client.DOM;
import com.google.gwt.user.client.ui.Label;

public class ZooGrid {

	private GridCell[][] zooGridCells = new GridCell[5][5];
	private Zoologico zoo;
	
	public ZooGrid(Zoologico zoo) {
		this.zoo = zoo;
	}
	
	public void montarZooGrid() {

		for (int i = 0; i < 5; i++) {
			for (int j = 0; j < 5; j++) {
				
				GridCell cell = new GridCell();
				Element element = DOM.getElementById("cell-" + Integer.toString(i) + Integer.toString(j)); 
				GridEventHandler mouseHandler = new GridEventHandler(element, zoo);
				Label label = Label.wrap(element);
				
				label.addMouseOverHandler(mouseHandler);
				label.addClickHandler(mouseHandler);
				label.addMouseOutHandler(mouseHandler);
				
				cell.setGridLabel(label);
				zooGridCells[i][j] = cell;
			}
		}
	}
	
	public GridCell getGridCell(int i, int j) {
		return zooGridCells[i][j];
	}
	

}
